/**
 * 
 */
package de.oszimtcc.timetable;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import de.oszimtcc.framework.BaseActivity;
import de.oszimtcc.framework.BaseApplication;
import de.oszimtcc.timetablecore.Timetable;
import de.oszimtcc.timetablehelper.ApiWebservice;
import de.oszimtcc.timetablehelper.RequestCache;

/**
 * @author Kooki
 *
 */
public class TimetableApplication extends BaseApplication
{
	private static TimetableApplication instance;
	private Timetable actualTimetable;
	private String actualClass;

	public void onCreate()
	{
		super.onCreate("StundenplanApp","OSZIMT-Stundenplan",null);
		instance = this;
	};
	
	public static TimetableApplication getInstance() 
	{
		return instance != null ? instance : new TimetableApplication();
	}
	
    public Timetable getActualTimetable()
    {
    	this.actualClass = getActualClass();
    	if(actualTimetable == null)
    		actualTimetable = RequestCache.getInstance(actualClass).GetLatestTimetable();
    	return actualTimetable;
    }
    
    public String getActualClass()
    {
    	return actualClass != null ? actualClass : activity.GetStringPreference("Class");
    }

    public void setActualTimetable(Timetable actualTimetable)
    {
    	this.actualTimetable = actualTimetable;
    }
}
